/**
 * Created by mill on 2017/12/9.
 */

var mysql = require('mysql');
var pool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'test'
});

pool.getConnection(function (err, connection) {
    // Use the connection
    connection.query('select * from userInfo  where u_id=?', [9],function (error, rows, fields) {
        // 回收连接
        connection.release();

        // 错误处理在回收之后
        if (error) throw error;
        rows.forEach((item)=> {
            console.log('the user name is %s!', item.u_name);
        });
        // 连接已回收不可再使用
    });
});